package com.njmaomao.gj.pyot.common;

/**
 * 响应
 */
public class ResponseCode {

    public static final String DESC_SUCCESS = "成功";

    public static final String DESC_SYSTEM_ERROR = "系统开小差了，请稍候再试";

    /**
     * common<br/>
     * 应用层使用此ResponseCode
     */
    public static class COMMON {
        public static final ResponseCode SUCCESS = new ResponseCode("100", DESC_SUCCESS, Systems.GJ_FACTORY);
        public static final ResponseCode INVALID_PARAMETER = new ResponseCode("400", "非法参数", Systems.GJ_FACTORY);
        public static final ResponseCode NULL_MALL_ID = new ResponseCode("401", "商城Id不能为空", Systems.GJ_FACTORY);
        public static final ResponseCode SYSTEM_ERROR = new ResponseCode("500", DESC_SYSTEM_ERROR, Systems.GJ_FACTORY);
        public static final ResponseCode BUSINESS_ERROR = new ResponseCode("600", "业务异常", Systems.GJ_FACTORY);
        public static final ResponseCode API_ERROR = new ResponseCode("700", "接口调用失败", Systems.GJ_FACTORY);
    }


    public static class PAYTO {

        public static final ResponseCode SYSTEM_ERROR = new ResponseCode("1001", "系统错误", Systems.PAY_YTO);
        public static final ResponseCode SYSTEM_BIZ_FAIL = new ResponseCode("1002", "系统业务处理失败", Systems.PAY_YTO);
        public static final ResponseCode EXTERNAL_SYSTEM_ERROR = new ResponseCode("1003", "依赖系统调用错误:%1$s", Systems.PAY_YTO);
        public static final ResponseCode EXTERNAL_SYSTEM_BIZ_FAIL = new ResponseCode("1004", "依赖系统业务处理失败:%1$s", Systems.PAY_YTO);
        public static final ResponseCode REQUEST_ERROR = new ResponseCode("1005", "非法请求", Systems.PAY_YTO);


        public static final ResponseCode INVALID_SIGN = new ResponseCode("3001", "签名校验未通过", Systems.PAY_YTO);
        public static final ResponseCode UNKNOW_APPID = new ResponseCode("3002", "未知appId", Systems.PAY_YTO);
        public static final ResponseCode UNKNOW_ORDERTYPE = new ResponseCode("3003", "未知订单类型", Systems.PAY_YTO);
        public static final ResponseCode UNKNOW_MCHID = new ResponseCode("3004", "未知mchId", Systems.PAY_YTO);
        public static final ResponseCode CERTRESTTEMPLATE_ERROR = new ResponseCode("3005", "建立安全CertRestTemplate错误", Systems.PAY_YTO);
        public static final ResponseCode CLOSED_OR_PAIED = new ResponseCode("3006", "订单已支付或已关闭,不允许支付[支付]", Systems.PAY_YTO);
        public static final ResponseCode DECRYPTWECHATREFUNDNOTIFY_ERROR = new ResponseCode("3007", "解密微信退款通知错误: %1$s", Systems.PAY_YTO);
        public static final ResponseCode UNKNOW_ORDER = new ResponseCode("3008", "该订单暂无支付记录", Systems.PAY_YTO);
        public static final ResponseCode ORDER_REPEAT = new ResponseCode("3009", "其它系统或商户下已存在该订单,请更换订单号", Systems.PAY_YTO);
        public static final ResponseCode ORDER_NOT_ALLOW_PAY = new ResponseCode("3010", "订单不允许支付[订单]", Systems.PAY_YTO);
        public static final ResponseCode UNSUPPORT_PAY_TYPE = new ResponseCode("3011", "暂不支持该支付类型: %1$s", Systems.PAY_YTO);
        public static final ResponseCode TOTALFEE_DISCORD = new ResponseCode("3012", "支付金额不一致", Systems.PAY_YTO);
        public static final ResponseCode ORDER_REFUNDED = new ResponseCode("3013", "订单已申请退款", Systems.PAY_YTO);
        public static final ResponseCode UNSUPPORT_ORDER_TYPE = new ResponseCode("3014", "不支持该订单类型", Systems.PAY_YTO);
        public static final ResponseCode WECHAT_CALL_ERROR = new ResponseCode("3015", "微信接口调用异常: %1$s", Systems.PAY_YTO);
        public static final ResponseCode WECHAT_BIZ_FAIL = new ResponseCode("3016", "微信接口业务失败", Systems.PAY_YTO);
        public static final ResponseCode PAYMENT_CONFIG_INCOMPLETE = new ResponseCode("3017", "配置信息不完整，请检查秘钥、证书", Systems.PAY_YTO);
        public static final ResponseCode REFUND_AMOUNT_ERROR = new ResponseCode("3018", "退款金额不一致", Systems.PAY_YTO);

    }

    private String code;

    private String desc;

    private Systems systems;

    public ResponseCode(String code, String desc, Systems systems) {
        this.code = code;
        this.desc = desc;
        this.systems = systems;
    }

    public String getCode() {
        if (getSystems() == Systems.GJ_FACTORY) {
            return this.code;
        } else {
            return getSystems().getId() + this.code;
        }
    }

    public String getDesc() {
        return desc;
    }

    public Systems getSystems() {
        return systems;
    }

}
